/*
 * @Date: 2022-06-07 10:55:30
 * @LastEditors: 春贰
 * @gitee: https://gitee.com/chun22222222
 * @github: https://github.com/chun222
 * @Desc:
 * @LastEditTime: 2022-11-10 12:07:03
 * @FilePath: \golang-opc-test\main.go
 */
package main

import (
	"fmt"
	"time"

	"github.com/konimarti/opc"
)

func main() {
	opctest()
}

func opctest() {

	defer func() {
		if err := recover(); err != nil {
			fmt.Println("opc服务异常！", err)
		}

	}()
	s := opc.NewAutomationObject().GetOPCServers("localhost")

	fmt.Println(s)

	// 创建一个新的opc客户端
	//	opcs, _ := opc.CreateBrowser("Matrikon.OPC.Simulation.1", []string{"localhost"})

	//opc.PrettyPrint(opcs)

	// client, _ := opc.NewConnection(
	// 	"Kepware.KEPServerEX.V6",                   // ProgId
	// 	[]string{"localhost"},                      //  OPC servers nodes
	// 	[]string{"Test.EQP1.WF1", "Test.EQP1.WF2"}, // slice of OPC tags
	// )
	// defer client.Close()

	// // read single tag: value, quality, timestamp
	// fmt.Println(client.ReadItem("Test.EQP1.WF1"))

	// client.Write("Test.EQP1.WF1", "Test.EQP1.WF1")

	// // read all added tags
	// fmt.Println(client.Read())

	time.Sleep(10 * time.Second)
}
